// [[ OnflowGenerator File UUID: c0b184839f1a4453b9136aa985ec044a  ]]
package com.itdct.onflow.system.task.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.task.qo.SysTaskEditQo
import com.itdct.onflow.system.task.qo.SysTaskSearchQo
import com.itdct.onflow.system.task.service.SysTaskService
import com.itdct.onflow.system.task.vo.SysTaskDetailVo
import com.itdct.onflow.system.task.vo.SysTaskListVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-19 16:39:00
 * @version 1.0
 * @description 定时任务接口控制
 */
@Tag(name = SysTaskController.moduleName)
@RestController
@RequestMapping(value = ["/sysTask"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysTaskController(
    val sysTaskService: SysTaskService
) : BaseSysController() {
    companion object {
        const val moduleName = "定时任务"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysTaskEditQo): RespVo<Long> {
        return sysTaskService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysTaskEditQo): RespVo<Unit> {
        return sysTaskService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysTaskEditQo): RespVo<Unit> {
        return sysTaskService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysTaskSearchQo): RespVo<SysTaskDetailVo> {
        return sysTaskService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysTaskSearchQo): RespPageVo<SysTaskListVo> {
        return sysTaskService.page(qo, getContext())
    }

    @Operation(summary = moduleName + "立即执行")
    @PostMapping("/runImmediately.adw")
    fun runImmediately(@RequestBody eo: SysTaskEditQo): RespVo<Unit> {
        return sysTaskService.runImmediately(eo, getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "任务名下拉选")
    @PostMapping("/selectNameList.adw")
    fun selectNameList(@RequestBody qo: SysTaskSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysTaskService.selectNameList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}